import { createRequest } from '/@/api/service';
const module = 'ib/deliver/order/v1/AppWoDeliverApi';

/**
 * @function 查询运送工单列表
 * @param data
 * @param header
 * @returns {Promise}
 */
function QUERY_APP_WO_DELIVER_LIST(
  data: AppWoDeliverApi.QueryAppWoDeliverListReq,
  header: object = {},
): Promise<AppWoDeliverApi.QueryAppWoDeliverListResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/queryAppWoDeliverList`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 查看运送工单详情
 * @param data
 * @param header
 * @returns {Promise}
 */
function QUERY_APP_WO_DELIVER_DETAIL(
  data: AppWoDeliverApi.QueryAppWoDeliverDetailReq,
  header: object = {},
): Promise<AppWoDeliverApi.QueryAppWoDeliverDetailResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/queryAppWoDeliverDetail`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 状态运送工单数量统计
 * @param data
 * @param header
 * @returns {Promise}
 */
function COUNT_APP_STATUS_QUANTITY(
  data: AppWoDeliverApi.CountStatusQuantityReq,
  header: object = {},
): Promise<AppWoDeliverApi.CountStatusQuantityResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/countAppStatusQuantity`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 接单
 * @param data
 * @param header
 * @returns {Promise}
 */
function RECEIVE_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/receiveAppTask`, data, header, 'POST');
}

/**
 * @function 立即抢单
 * @param data
 * @param header
 * @returns {Promise}
 */
function RUSH_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/rushAppTask`, data, header, 'POST');
}

/**
 * @function 工单处理-开始运送
 * @param data
 * @param header
 * @returns {Promise}
 */
function START_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/startAppTask`, data, header, 'POST');
}

/**
 * @function 工单处理-运送结束
 * @param data
 * @param header
 * @returns {Promise}
 */
function END_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/endAppTask`, data, header, 'POST');
}

/**
 * @function 回退
 * @param data
 * @param header
 * @returns {Promise}
 */
function BACK_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/backAppTask`, data, header, 'POST');
}

/**
 * @function 运送工单评价
 * @param data
 * @param header
 * @returns {Promise}
 */
function EVALUATE_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/evaluateAppTask`, data, header, 'POST');
}

/**
 * @function 修改运送工单
 * @param data
 * @param header
 * @returns {Promise}
 */
function UPDATE_APP_WO_DELIVER(
  data: AppWoDeliverApi.UpdateAppWoDeliverReq,
  header: object = {},
): Promise<AppWoDeliverApi.UpdateAppWoDeliverResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/updateAppWoDeliver`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 新增运送工单
 * @param data
 * @param header
 * @returns {Promise}
 */
function INSERT_APP_WO_DELIVER(
  data: AppWoDeliverApi.InsertAppWoDeliverReq,
  header: object = {},
): Promise<AppWoDeliverApi.InsertAppWoDeliverResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/insertAppWoDeliver`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 删除运送工单
 * @param data
 * @param header
 * @returns {Promise}
 */
function DELETE_APP_WO_DELIVER(
  data: AppWoDeliverApi.DeleteWoDeliverReq,
  header: object = {},
): Promise<AppWoDeliverApi.DeleteWoDeliverResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/deleteAppWoDeliver`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 运送工单确认
 * @param data
 * @param header
 * @returns {Promise}
 */
function CONFIRM_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/confirmAppTask`, data, header, 'POST');
}

/**
 * @function 运送工单撤销
 * @param data
 * @param header
 * @returns {Promise}
 */
function CANCEL_APP_TASK(
  data: AppWoDeliverApi.AddAppWoDeliverEventReq,
  header: object = {},
): Promise<AppWoDeliverApi.AddAppWoDeliverEventResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/cancelAppTask`, data, header, 'POST');
}

export {
  QUERY_APP_WO_DELIVER_LIST,
  QUERY_APP_WO_DELIVER_DETAIL,
  COUNT_APP_STATUS_QUANTITY,
  RECEIVE_APP_TASK,
  RUSH_APP_TASK,
  START_APP_TASK,
  END_APP_TASK,
  BACK_APP_TASK,
  EVALUATE_APP_TASK,
  UPDATE_APP_WO_DELIVER,
  INSERT_APP_WO_DELIVER,
  DELETE_APP_WO_DELIVER,
  CONFIRM_APP_TASK,
  CANCEL_APP_TASK,
};
